package com.yy.job.boot.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yy.job.boot.service.Case2Service;
import com.yy.job.common.utils.BaseResult;

@Controller
@RequestMapping("/boot/job/step")
public class JobStepBootController {
	
	private Logger logger = LoggerFactory.getLogger(this.getClass());
	
	@Autowired
	private Case2Service case2Service;

	/**
	 * 创建多步骤并且执行成功的任务
	 *
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/createTrue.json", method = RequestMethod.GET)
	@ResponseBody
	public BaseResult<Long> createTrue(HttpServletRequest request,HttpServletResponse response) throws Exception {
		logger.info("createTrue");
		
		// 创建job
		Long create = case2Service.createTrue(request, null);
		
		return BaseResult.success(create);
	}

	/**
	 * 创建多步骤，且存在1个执行失败的任务
	 *
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/createFalse.json", method = RequestMethod.GET)
	@ResponseBody
	public BaseResult<Long> createFalse(HttpServletRequest request,HttpServletResponse response) throws Exception {
		logger.info("createFalse");
		
		// 创建job
		Long create = case2Service.createFalse(request, null);
		
		return BaseResult.success(create);
	}
	
}
